/*oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoO*/
/*
Authors: Ram Ovadia 201374022 and Lior Fass 300069705
Project: HW Assignment 4 
Description: This is the header of the Server module used in the project.  
*/
/*oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoO*/

#ifndef SERVER_H
#define SERVER_H

#include <winsock2.h>
#include "common_utils.h"
#include "SocketSendRecvTools.h"
#include "map.h"

/*
 * struct that holds shared resources for server.
 * server_IP_addr - string containing the ip in dotted decimal.
 * maxClients - maximum allowd connections.
 * serverListenSocket - the socket for listening.
 * log_file - file handle for printing to log.
 * graph - the graph for the dijkstra alg.
 * gps_semaphore - semaphore for signaling the GPS process to quit.
 * ThreadHandles - array of maxClients thread handles for serving clients.
 * ThreadSockets - array of maxClients Sockets for each serving thread.
 */
typedef struct server_attr_t
{
	char *server_IP_addr;
	int maxClients;
	SOCKET serverListenSocket;
	FILE *log_file;
	HANDLE graphMutex;
	Map *graph;
	HANDLE gps_semaphore;
	HANDLE *ThreadHandles;
	SOCKET *ThreadSockets;
} Server_attr;

/*
 * struct that holds the input for the serving thread
 * server_attr - shared resources of the server
 * Ind - the index of the running thread
 */
typedef struct service_thread_attribures_t
{
	Server_attr *server_attr;
	int Ind;
} Service_thread_attr;

int server_main(char* IpAddress,char* graphTxt,int maxClients, char* ServerLogFilename);

#endif //SERVER_H